<!--规则结果-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="d" uri="http://www.trkj.com/tr1702/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/default/easyui.css"/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/icon.css"/>" />
</head>
<body>
	<script type="text/javascript">
	var placework_state= function(value,row,index){
		var pic="";
		var state = row.gzddState;
		if(state==0){
			pic = "<input type='checkbox' disabled='disabled'>";
		}else if(state==1){
			pic="<input type='checkbox' checked  disabled='disabled'>";
		}
		return pic;
	}
	var placework_button =function(value,row,index){
		var placeworkonly ="";
		var placeworkedit ="";
		var placeworkdel ="";
		<d:g id="27"> placeworkonly = "<a style='' btn='cell_btn_only' onclick='placeworkonlyrule(" + row.gzddId + ","+row.gzddState+")'></a>";</d:g>
		<d:g id="27"> placeworkedit = "<a style='' btn='cell_btn_edit' onclick='placeworkeditrule(" + row.gzddId + ")'></a>";</d:g>
		<d:g id="27"> placeworkdel = " <a btn='cell_btn_del' onclick='placeworkdelrule(" + row.gzddId + ")'></a>";</d:g>
		return  placeworkonly +placeworkedit +placeworkdel; 
	}
		/*禁用*/
		var placeworkonlyrule =function(gzddId,gzddState){
			$('#update-placework').dialog("close");
			var jy_state =1;
			if(gzddState==1){
				jy_state=0;
				$.messager.confirm('确认', '您确定要打开该规则吗？', function(v){
					if(v){
						$.post("update_placeworkstate", {gzddId: gzddId,gzddState:jy_state}, function(v){
							if(v.success){
								$('#placework_tb').datagrid('reload');
							}else{
								$.messager.alert('错误', v.message);
							}
						});
					}else{
						
					}
					
				}); 
			}else if(gzddState==0){
				jy_state=1;
				$.messager.confirm('确认', '您确定要关闭该规则吗？', function(v){
					if(v){
						$.post("update_placeworkstate", {gzddId: gzddId,gzddState:jy_state}, function(v){
							if(v.success){
								$('#placework_tb').datagrid('reload');
							}else{
								$.messager.alert('错误', v.message);
							}
						});
					}else{
						
					}
					
				}); 
			}
			
		}
		/*修改*/
		var placeworkeditrule=function(gzddId){
			$('#update-placework').dialog("open");
			$('#placework_update').form('load','load_placework?gzddId='+gzddId);
		}
		/*删除*/
		var placeworkdelrule= function(gzddId){
			$('#update-placework').dialog("close");
			$.messager.confirm('确认','您确认要删除吗？',function(v){
				if(v){
					$.post("delete_placework",{gzddId:gzddId},function(v){
						if(v.success){
							$('#placework_tb').datagrid('reload');
						}else{
							$.messager.alert('错误',v.message);
						}
					});
				}else{
					
				}
				
			});
		}
		$(function() {
			$(".xz_placework").linkbutton({
				onClick : function() {
					$("#dd-placework").dialog("open");
				}
			});
			$("#placework_tb").datagrid({
				onLoadSuccess:function(){
					$("a[btn=cell_btn_edit]").linkbutton({iconCls:'icon-update_red', plain:true});
					$("a[btn=cell_btn_del]").linkbutton({iconCls:'icon-delete_red', plain:true});
					$("a[btn=cell_btn_only]").linkbutton({iconCls:'icon-changes', plain:true});
				}
			});
			//模糊查询
				$("#placework_seebyname").linkbutton({
				onClick:function(){
					var SeeText = $("#placework_seebytext").textbox("getText");
					alert(SeeText);
					 $("#placework_tb").datagrid({url:'modaddSeslect_placework?text='+SeeText,method:'get'});
					$("#placework_tb").datagrid("reload"); 
				}
			});
			//双击修改
			$('#placework_tb').datagrid({
				onDblClickRow: function(index, row){
					$('#update-placework').dialog("open");
					$('#placework_update').form('load','load_placework?gzddId='+row.gzddId);
				}
			});
			
			//

		});
	
		 
	</script>
	<table id="placework_tb" class="easyui-datagrid" style="width: 400px; height: 250px"
		data-options="
				fitColumns:true,
				fit:true,
       			url:'queryByto_placework',
				pagination:true,     
				pageSize:5,     
				pageList: [5,10,15,20,25], 
				rownumbers:true,
				Striped:true, 
				singleSelect:true,
				striped:true,
				toolbar:'#tool_placework'
        ">
		<thead>
			<tr>
				<th data-options="field:'gzddId',width:30,align:'center'">工作地点编号</th>
				<th data-options="field:'gzddName',width:70,align:'center'">工作地点名称</th>
				<th data-options="field:'gzddRemark',width:70,align:'center'">备注</th>
				<th data-options="field:'gzddPerson',width:50,align:'center'">创建者</th>
				<th data-options="field:'gzddCtime',width:80,align:'center'
				,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}">创建日期</th>
				<th data-options="field:'gzddUtime',width:80,align:'center',formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}">更新日期</th>
				<th data-options="field:'gzddState',width:20,align:'center',formatter:placework_state">
					状态
				</th>
				<th data-options="field:'xxx',width:60,formatter:placework_button">操作</th>   
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
	<!--工具-->
	<d:g id="27">
	<div id="tool_placework" style="padding-left: 30px;">
		<a class="easyui-linkbutton xz_placework"
			data-options="iconCls:'icon-add',text:'新增',plain:true,iconAlign:'left'"></a>
			<input class="easyui-textbox" id="placework_seebytext" data-options="prompt:'请输入名称'"> 
			<a class="easyui-linkbutton"
			data-options="text:'搜索'" id="placework_seebyname"> </a>
	</div>
	</d:g>
	<div id="dd-placework" class="easyui-dialog" title="工作地点"
		data-options="
         width:440,
         height:260,
	     resizable:false,
	     modal:true,
	     closed:true,
	     buttons:[{
				text:'添加',
				width:60,
				handler:function(){
					$('#placework_add').form({
						url:'insert_placework',
						
						onSubmit:function(params){
							params['gzddName']=$('#placework_name').textbox('getText');
							params['gzddRemark']=$('#placework_marks').val();
							if($('#placework_check').is(':checked')){
								params['gzddState']=parseInt(1);
							}else{
								params['gzddState']=parseInt(0);
							}
							
						},
						success:function(v){
							v = eval('('+v +')');
							if(v.success){
								$.messager.alert('恭喜', '添加成功');
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						$.messager.progress('close');// 如果提交成功则隐藏进度条
						$('#placework_tb').datagrid('reload');
						$('#placework_add').form('reset');
						$('#dd-placework').dialog('close');
						}
					}).submit();
				}
				},{
				text:'取消',
				width:60,	
				handler:function(){
					$('#dd-placework').dialog('close');
				}
			}]
        ">
		<div style="margin-left: 21%; margin-top: 10px;">
			<form action="" id="placework_add" style="text-align: right;">
				<table>
					
					<tr>
						<td><span style="color: red;">*</span>名称</td>
						<td><input class="easyui-textbox"
							data-options="required:true" id="placework_name"></td>
					</tr>
					<tr>
						<td><span style="color: red;"> </span>备注</td>
						<td><input class="easyui-textbox" data-options="height:60,multiline:true" id="placework_marks"></td>
					</tr>
					<tr>
						<td><span style="color: red;"> </span></td>
						<td><span style="padding-right:5px;">停用</span>
						<input type="checkbox" value='0' id="placework_check">
					</tr>
				</table>
			</form>
		</div>
	</div>
	
	<!-- 修改 -->
	<div id="update-placework" class="easyui-dialog" title="工作地点"
		data-options="
         width:440,
         height:300,
	     resizable:false,
	     modal:true,
	     closed:true,
	     buttons:[{
				text:'保存',
				width:60,
				handler:function(){
					$('#placework_update').form({
						
						url:'update_placework',
						onSubmit:function(params){
							
							if($('#placework_check_update').is(':checked')){
								params['gzddState']=parseInt(1);
							}else{
								params['gzddState']=parseInt(0);
							}
							
						},
						success:function(v){
							v = eval('('+v +')');
							if(v.success){
								$.messager.alert('恭喜', '修改成功');
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						$.messager.progress('close');// 如果提交成功则隐藏进度条
						$('#placework_tb').datagrid('reload');
						$('#placework_update').form('reset');
						$('#update-placework').dialog('close');
						}
					}).submit();
				}
				},{
				text:'取消',
				width:60,	
				handler:function(){
					$('#update-placework').dialog('close');
				}
			}]
        ">
		<div style="margin-left: 21%; margin-top: 10px;">
			<form action="" id="placework_update" style="text-align: right;">
				<table>
					<tr style="">
						<td><span style="color: red;">*</span>编号</td>
						<td><input class="easyui-textbox"
							name="gzddId" data-options="required:true,readonly:true" id="placework_id_update"></td>
					</tr>
					<tr>
						<td><span style="color: red;">*</span>名称</td>
						<td><input class="easyui-textbox"
							name="gzddName" data-options="required:true" id="placework_name_update"></td>
					</tr>
					<tr>
						<td><span style="color: red;"> </span>备注</td>
						<td><input class="easyui-textbox" name="gzddRemark" data-options="height:60,multiline:true" id="placework_marks_update"></td>
					</tr>
					<tr>
					
						<td><span style="color: red;"> </span></td>
						<td><span style="padding-right:5px;">停用</span>
						<input name="gzddState" type="checkbox" value='1' id="placework_check_update">
					</tr>
				</table>
			</form>
		</div>
	</div>
	
</body>
</html>